/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * <p>Project: redis2021 - SpringConfig
 * <p>Powered by webrx On 2021-12-06 13:52:46
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
@Configuration
@ComponentScan("cn.webrx.entity")
public class SpringConfig {
    @Bean(destroyMethod = "close")
    public Jedis jedis(){
        Jedis jedis = new Jedis("localhost",6379);
        return jedis;
    }

    @Bean
    public JedisPoolConfig jedisPoolConfig(){
        JedisPoolConfig jpc = new JedisPoolConfig();
        jpc.setMaxIdle(10);
        jpc.setMaxTotal(30);
        return jpc;
    }

    @Bean(destroyMethod = "close")
    public JedisPool jedisPool(){
        JedisPool jp = new JedisPool(jedisPoolConfig(),"localhost",6379);
        return jp;
    }
}
